/*
 * Copyright 2006-2007 S W McIlroy
 * Licensed  under the  Apache License,  Version 2.0  (the "License");
 * you may not use  this file  except in  compliance with the License.
 * You may obtain a copy of the License at
 *
 *   http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed  under the  License is distributed on an "AS IS" BASIS,
 * WITHOUT  WARRANTIES OR CONDITIONS  OF ANY KIND, either  express  or
 * implied.
 *
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package org.mockfu.testng;

import static org.mockfu.Mocks.*;

import java.util.GregorianCalendar;
import java.util.List;

import org.mockfu.ExpectationFailure;
import org.mockfu.MockControl;
import org.testng.annotations.Test;

public class VerifierTest extends Verifier
{
    private static GregorianCalendar injectable;


    @Test(expectedExceptions=ExpectationFailure.class)
    public void verification()
    {
        MockControl<List<String>> list1 = new MockControl<List<String>>() {};
        MockControl<List<String>> list2 = new MockControl<List<String>>() {};
        MockControl<List<String>> list3 = new MockControl<List<String>>() {};

        list1.expectsOnce().add( "one" );
        list2.expectsOnce().add( "two" );
        list3.expectsOnce().add( "three" );

        list1.mock().add( "one" );
        list2.mock().add( "two" );

    }

    /**
     * This or the test below will fail if the mocks were not ejected.
     */
    @Test
    public void injection1()
    {
        assertThat(injectable, null);

        MockControl<GregorianCalendar> gregorianCalendar = MockControl.of(GregorianCalendar.class);
        gregorianCalendar.injectInto(VerifierTest.class);
    }

    /**
     * This or the test above will fail if the mocks were not ejected.
     */
    @Test
    public void injection2()
    {
        assertThat(injectable, null);

        MockControl<GregorianCalendar> gregorianCalendar = MockControl.of(GregorianCalendar.class);
        gregorianCalendar.injectInto(VerifierTest.class);
    }

}
